package cn.gov.cus.rmftquartz.mappers.oracle;

import cn.gov.cus.rmftquartz.entity.RskEntryVo;
import cn.gov.cus.rmftquartz.mappers.oracle.provider.EntryProvider;
import org.apache.ibatis.annotations.*;
import org.apache.ibatis.mapping.StatementType;

import java.util.List;
import java.util.Map;

/**
 * @author wxming.
 * @date 2018/2/11.
 */
@Mapper
public interface EntryMapper {

    @Update(value = "UPDATE RULE SET REAL_END_DATE=TO_DATA(#{data},'yyyy-MM-dd HH24:mi:ss') "+
            "WHERE RULE_ID=#{oneEnName}")
    void updateRuleRealEndDate(@Param(value = "oneEnName")String oneEnName,@Param(value = "data")String data);

    @InsertProvider(type = EntryProvider.class,method = "toLockManifest")
    int toLockManifest(@Param("rskEntryVo")RskEntryVo rskEntryVo);

    @Update("<script>"
            +"<foreach collection='list' item='item' index='index' open='begin' close='end;'>"
            +"UPDATE RSK_ENTRY SET IS_FLAG = '0',UNRSK_TYPE='1' WHERE ID = "
            +"#{item.id};"
            +"</foreach>"
            +"</script>")
    int decontrol(@Param("list")List<RskEntryVo> list);

    /**
     * 调用存储过程！！！
     * @param map
     */
    @Select(" call support_pkg.usp_getcounter(#{type},#{customsCode},#{iEFlag},#{nCounter,mode=OUT,jdbcType=INTEGER})")
    @Options(statementType = StatementType.CALLABLE)
    void getCounter(Map<String,Object> map);

    /**
     * 防止sql注入的写法
     * @param paraList
     * @return
     */
    @SelectProvider(type = EntryProvider.class,method = "doSelectByObj")
    List<RskEntryVo> doSelectByObj(RskEntryVo paraList);//不能写@Param()。
}
